package com.designpatterns.proxy.dynamicproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class main {
    public static void main(String[] args) {
        ISubject subject = (ISubject) Proxy.newProxyInstance(SubjectA.class.getClassLoader(), SubjectA.class.getInterfaces(), new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

                System.out.println("==========" + method.getName() + "=============");
                System.out.println("begin...");
//                Object result = method.invoke(new SubjectA(),args);
//                for (Class clazz : proxy.getClass().getInterfaces()) {
//                    System.out.println(clazz.getName());
//                }
//                System.out.println(proxy);
                System.out.println("end...");
//                return result;
                return null;
            }
        });
        subject.request();
    }
}
